package persistent;


import persistent.*;

import java.util.Date;
import java.util.HashMap;

/**
 * A real invoice can be generated from unpaid treatment records between a patient-doctor using this class.
 * We have left deciding the price of a treatment to the receptionist.
 * Will wait for client's orders on pricing and abstractions for payment.
 * @author Winfred Nadeau
 *
 */
public class Invoice extends Record{

	/**
	 * each line has a treatment record and a price for that
	 */
	private HashMap<TreatmentRecord,Integer> lineItems;
	
	/**
	 * Only set at instantiation, this is the date of the invoice creation.
	 */
	private Date date;
	/**
	 * the total price of this invoice/bill
	 */
	private int totalPrice;
	/**
	 * To create a blank invoice, we must know the patient and the doctor to keep the relationship
	 * @param doc
	 * @param patient
	 */
	public Invoice (Doctor doc, Patient patient){
		this.setDate(new Date());
		this.totalPrice = 0;
		this.lineItems = new HashMap<TreatmentRecord, Integer>();
	}
	/**
	 * add to this invoice's bill
	 * @param record
	 * @param price
	 */
	public void addLineItem(TreatmentRecord record, int price){
		lineItems.put(record,(Integer)price);
		totalPrice += price;
	}
	/**
	 * remove a line from this invoices bill
	 * @param record the treatment record you want to take off
	 */
	public void removeLineItem(TreatmentRecord record){
		int price = (Integer) lineItems.remove(record);
		totalPrice -= price;
	}
	public HashMap<TreatmentRecord,Integer> getLineItems() {
		return lineItems;
	}
	public void setDate(Date date) {
		this.date = date;
	}
	public Date getDate() {
		return date;
	}
	public int getTotalPrice(){
		return this.totalPrice;
	}
}
